package JDBC.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class GetConnectionUtils {
    private GetConnectionUtils() {
    }

    public static Connection getConnection() throws Exception {
        String rootDir = System.getProperty("user.dir");
        FileReader fr = new FileReader("mysqlData\\druidProp.properties");
        Properties prop = new Properties();

        prop.load(fr);
        fr.close();

        //String url = prop.getProperty("url");
        //String user = prop.getProperty("user");
        //String password = prop.getProperty("password");

        //Connection cnt = DriverManager.getConnection(url, user, password);
        DataSource ds = DruidDataSourceFactory.createDataSource(prop);

        return ds.getConnection();


    }

}
